/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ideastec.mipyme.persistence.email;

import java.util.List;

import com.ideastec.mipyme.model.email.Email;
import com.ideastec.mipyme.persistence.DAOPadre;
import com.ideastec.mipyme.repository.email.RepositorioEmail;

/**
 *
 * @author Diego Rafael Graf
 */

public class DAOEmail extends DAOPadre<Email> implements RepositorioEmail{
    
    @Override 
    protected Class<Email> getClase(){
        return Email.class;
    }
    
    @Override
    public List<Email> buscarTodos() throws Exception{
        try{
            return this.getHibernateTemplate().find("from " + persistentClass.getName() + " order by email asc");
        }
        catch(Exception e){
            throw new Exception(e);
        }
    }    
    
    @Override
    public List<Email> buscarEmail(Email email) throws Exception{
        try{
            return this.getHibernateTemplate().find("from " + persistentClass.getName() + " where email = '" + email.getEmail() + "'");
        }
        catch(Exception e){
            throw new Exception(e);
        }
    }
    
}
